package tarea;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 
 * clase para serializar las tareas y guardarlas en el archivo
 * @author Lenovo
 *
 */
public class tareaGuardar {
	
	private List<tarea> tareas;
	
	
	public void guardar(){
		String filename = "tareas.txt";
		tarea t1 = new tarea();
		t1.setNombre("T1"); t1.setVisib(true);
		
		tarea t2 = new tarea();
		t2.setNombre("T2"); t2.setVisib(false);
		
		tarea t3 = new tarea();
		t3.setNombre("T3"); t3.setVisib(true);
		
	/**	obTareas OT=new obTareas();
    	tareas=OT.generarLista();*/
				
		tareas=new ArrayList();
		tareas.add(t1);
		tareas.add(t2);
		tareas.add(t3);
	 
		
		FileOutputStream fos = null;
		ObjectOutputStream out = null;
		try {
			fos = new FileOutputStream(filename);
			out = new ObjectOutputStream(fos);
			out.writeObject(tareas);
			out.close();
	//		System.out.println("Object Persisted");
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}
	
	public List<tarea> getTareas(){
		return tareas;
	}
	
	public void setTareas( List<tarea> t){
		tareas=t;
	}

}
